package com.ymdx.util.tool;

import java.util.List;
import java.util.Map;

/**
 * 生成hql语句
 * Created by yangliwei on 2017/8/15.
 */
public class HqlUtil {

    //生成and的hql语句
    public static void andHql(final StringBuilder hql, final Map<String,Object> args, final List params){
        int i = 0;
        for (String temp : args.keySet()) {
            if (args.get(temp) instanceof String)
                hql.append(" and " + temp + " like '%"+args.get(temp)+"%'");
            else {
                hql.append(" and " + temp + " = ?  ");
                params.add(args.get(temp));
            }
        }
    }
}
